/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | www.openfoam.com
     \\/     M anipulation  |
-------------------------------------------------------------------------------
    Copyright (C) 2024 AUTHOR,AFFILIATION
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Application
    calcWallShearStress

Description

\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
// #include "wallFvPatch.H"
#include "emptyFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

//-----参数设置------//
const word extract_time  = "0.5";
//-----参数设置------//

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

  Info<< "Reading field U\n" << endl;
  volVectorField U
  (
      IOobject
      (
          "U",
        //   runTime.timeName(),
          extract_time,
          mesh,
          IOobject::MUST_READ,
          IOobject::AUTO_WRITE
      ),
      mesh
  );

//   Info<< "Reading field U\n" << endl;
  volVectorField shearStress
  (
      IOobject
      (
          "shearStress",
        //   runTime.timeName(),
          extract_time,
          mesh,
          IOobject::NO_READ,
          IOobject::NO_WRITE
      ),
      mesh,
      dimensionedVector("shearStress", dimless, vector(0, 0, 0))
  );

    // 1. 获取模型中所有边界名
    const wordList patchNames = mesh.boundaryMesh().names();
    Info << "The patch names are: " << patchNames << endl;

    forAll(mesh.boundary(), patchI)
    {
        if(!isType<emptyFvPatch>(mesh.boundary()[patchI]) && patchNames[patchI] == "movingWall")
        {
            Info << "For boundary: " << patchNames[patchI] << endl;
  
            #include "method_1_my.H"
            // #include "method_2_interface.H"

            vectorField& ssp = shearStress.boundaryFieldRef()[patchI];
            ssp = USnGrad;

        } // endof if
    }

    shearStress.write();
    
    // outfile.close();
    Info<< nl;
    runTime.printExecutionTime(Info);

    Info<< "End\n" << endl;

    return 0;
}


// ************************************************************************* //
